//
//  FirstViewController.m
//  DailyGram
//
//  Created by TiOluwa Olarewaju on 8/20/12.
//  Copyright (c) 2012 MT. All rights reserved.
//

#import "FirstViewController.h"
#import <Parse/Parse.h>

@interface FirstViewController ()

@end

@implementation FirstViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    [PFUser logOut];
    
    
    
//    PFUser *mike = [PFUser user];
//    mike.username = @"mikeysambol";
//    mike.password = @"scrub";
//    mike.email = @"sambol.michael@gmail.com";
//    [mike setObject:@"4048941309" forKey:@"phone"];
//    [mike setObject:@"M" forKey:@"sex"];
//    [mike setObject:@"Michael" forKey:@"firstName"];
//    [mike setObject:@"Sambol" forKey:@"lastName"];
//    NSDate *date = [NSDate date];
//    [mike setObject:date forKey:@"birthday"];
//    [mike signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
//        if (!error) {
//            NSLog(@"GOOD!!");
//            // Hooray! Let them use the app now.
//        } else {
//            NSString *errorString = [[error userInfo] objectForKey:@"error"];
//            NSLog(errorString);
//            // Show the errorString somewhere and let the user try again.
//        }
//    }];
    
//    PFUser *to = [PFUser user];
//    to.username = @"tolarewaju3";
//    to.password = @"money";
//    to.email = @"tolarewaju3@gmail.com";
//    [to setObject:@"4048941309" forKey:@"phone"];
//    [to setObject:@"M" forKey:@"sex"];
//    [to setObject:@"TiOluwa" forKey:@"firstName"];
//    [to setObject:@"Olarewaju" forKey:@"lastName"];
//    NSDate *date1 = [NSDate date];
//    [to setObject:date1 forKey:@"birthday"];
//    [to signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
//        if (!error) {
//            NSLog(@"GOOD!!");
//            // Hooray! Let them use the app now.
//        } else {
//            NSString *errorString = [[error userInfo] objectForKey:@"error"];
//            NSLog(errorString);
//            // Show the errorString somewhere and let the user try again.
//        }
//    }];
//    
//    PFObject *follower = [PFObject objectWithClassName:@"Follower"];
//    [follower setObject:[PFUser currentUser] forKey:@"username"];
//    
//    PFQuery *query = [PFUser query];
//    [query whereKey:@"username" equalTo:@"mikeysambol"];
//    PFUser *michael = (PFUser*)[query getFirstObject];
//    NSLog(michael.objectId);
//    [follower setObject:michael forKey:@"following"];
//    [follower saveInBackground];
    
/*
    
    [PFUser logInWithUsernameInBackground:@"tolarewaju3" password:@"money"
                                    block:^(PFUser *user, NSError *error) {
                                        if (user) {
                                            NSLog(@"success");
                                            // Do stuff after successful login.
                                        } else {
                                            // The login failed. Check error to see why.
                                        }
                                    }];
    
    PFUser *user = [PFUser currentUser];
    
    PFObject *follower = [PFObject objectWithClassName:@"Follower"];
    [follower setObject:user forKey:@"following"];
    
    PFQuery *query1 = [PFUser query];
    [query1 whereKey:@"username" equalTo:@"mikeysambol"];
    PFUser *michael = (PFUser*)[query1 getFirstObject];
    [follower setObject:michael forKey:@"name"];
    [follower saveInBackground];

    
    PFQuery *query = [PFQuery queryWithClassName:@"Follower"];
    [query whereKey:@"following" equalTo:user];
    PFObject *follower1 = [query getFirstObject];
    PFUser *user1 = [follower1 objectForKey:@"name"];
    [follower1 fetchIfNeededInBackgroundWithBlock:^(PFObject *object, NSError *error) {
        [user1 fetch];
        NSLog(@" Here it is username %@", user1.username);
    }];
    
    
   */ 
    

	// Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

@end
